package edu.washington.tcss360.burningpenguins.BPGUI;

import java.util.List;
import java.beans.PropertyChangeListener;
import java.util.Map;

import javax.swing.Action;

/**
 * Abstract class to act as an action adapter for the burning penguins GUI.
 * Concrete classes will implement the actionPerformed method.
 * 
 * @author Sean
 * @version 1
 * @since 11/20/2013
 */
public abstract class BPActions implements Action {
	
	// Indexing for button/menu populating.
	protected static final int LOGIN = 0;
	protected static final int SUBMIT = 1; // author, reviewer, spc all use this for their respective submissions
	protected static final int GET_REVIEW = 2;
	protected static final int EDIT = 3;
	protected static final int ASSIGN = 4;
	protected static final int ACCEPT = 5;
	protected static final int DESIGNATE = 6;
	protected static final int VIEW_STATUS = 7;
	protected static final int VIEW_ASSIGN = 8;
	// end indexing
	
	private Map<String, Object> my_properties;
	private boolean my_state;
	private List<PropertyChangeListener> my_listeners;

	/**
	 * Generic addition of PropertyChangeListener.
	 * 
	 * @param arg0 the listener to add.
	 */
	@Override
	public void addPropertyChangeListener(PropertyChangeListener arg0) {
		// TODO Auto-generated method stub
		if(!my_listeners.contains(arg0)) my_listeners.add(arg0);

	}

	/**
	 * Returns the value associated with the key.
	 * 
	 * @param arg0 the key to look for.
	 * @return the value associated.
	 */
	@Override
	public Object getValue(String arg0) {
		// TODO Auto-generated method stub
		return my_properties.get(arg0);
	}

	/**
	 * @return Whether or not this action is enabled.
	 */
	@Override
	public boolean isEnabled() {
		// All actions are enabled--we hide the ones that are not.
		return my_state;
	}

	/**
	 * Assigns properties to the action.
	 * 
	 * @param arg0 the key to map.
	 * @param arg1 the value to map.
	 */
	@Override
	public void putValue(String arg0, Object arg1) {
		// TODO Auto-generated method stub
		this.my_properties.put(arg0, arg1);
	}

	/**
	 * Removes a listener from the action's list of listeners.
	 * 
	 * @param arg0 the listener to remove.
	 */
	@Override
	public void removePropertyChangeListener(PropertyChangeListener arg0) {
		// TODO Auto-generated method stub
		my_listeners.remove(arg0);
	}

	/**
	 * Enables/disables the action as appropriate.
	 * 
	 * @param arg0 whether or not this action is enabled.
	 */
	@Override
	public void setEnabled(boolean arg0) {
		// TODO Auto-generated method stub
		this.my_state = arg0;

	}

}
